var fs = require('fs')
var path = require('path')


module.exports.download = function(req, res) {
  var filePath = path.join('fonts', req.params.username,
    req.params.fontname, req.params.range + '.pbf')

  fs.readFile(filePath, function(err, pbf) {
    if (err) {
      return res.sendStatus(404)
    }

    res.set('Content-Encoding', 'gzip')
    res.set('Content-Type', 'application/x-protobuf')
    res.set('Expires', new Date(Date.now() + 604800000).toUTCString())
    return res.send(pbf)
  })
}